<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <title>富文本文件预览</title>
    <script th:inline="javascript">ctx = [[${ctx}]];</script>
</head>

<body>
<div class="row">
    <div id="err-info" class="alert alert-danger"></div>
</div>
<div class="row">
    <textarea id="content" name="content" th:value="${content}" rows="5">[[${content}]]</textarea>
</div>

<script th:src="${ctx}+'lib/jquery/jquery.min.js?v=2.1.4'" type="text/javascript"></script>
<script th:src="${ctx}+'lib/tinymce/tinymce.min.js'"></script>
<script th:src="${ctx}+'lib/tinymce/tinymce-custom.js'"></script>
<script th:inline="javascript">path = [[${path}]];edit = [[${edit}]];</script>
<script>
    $(function () {
        $("#err-info").hide();
        initEditor('content', edit, 'save');
    });

    function save() {
        $("#err-info").hide();
        if (typeof tinyMCE == 'function') {
            tinyMCE.triggerSave();
        }

        $.post(ctx + 'office/saveTxt', {
            filePath: path,
            content: $('#content').val()
        }, function(response) {
            if (response.code == 200) {
                window.close();
            } else {
                $("#err-info").text(response.msg);
                $("#err-info").show();
            }
        });
    }
</script>
</body>
</html>
